package zsj.androidknife;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

import zsj.androidknife.cache.CacheHelperImpl;
import zsj.androidknife.utils.BackgroundAction;
import zsj.androidknife.utils.SimpleBackgroundAction;
import zsj.androidknife.utils.SimpleUiAction;
import zsj.androidknife.utils.UiAction;

public class TestAc extends AppCompatActivity implements View.OnClickListener {
    private int i = 0;
    private EditText editText;
    private Button writeButton;
    private Button readButton;
    private ImageView imageView;
    private CacheHelperImpl cacheHelper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);   

        editText = (EditText) findViewById(R.id.text_view_id);
        writeButton = (Button) findViewById(R.id.writeButton);
        readButton = (Button) findViewById(R.id.readButton);
        imageView = (ImageView) findViewById(R.id.image_view_id);

        writeButton.setOnClickListener(this);
        readButton.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        if (v.equals(writeButton)) {
            AndroidKnife.getThreadUtils().startSimpleBackgroundTask(new SimpleBackgroundAction() {
                @Override
                public void doInBackground() {
                    //这里执行耗时的后台任务
                }
            }, new SimpleUiAction() {
                @Override
                public void doInUI() {
                    //这里执行任务完成后的回调
                }
            });
        }
        if (v.equals(readButton)) {
        }
    }

    private void toast(String s)
    {
        Toast.makeText(this,s,Toast.LENGTH_SHORT).show();
    }
}
